let ytxszbChart = echarts.init(document.getElementById('ytxszb'));
let ytxszbOption = {
	backgroundColor: '#ffffff',
	tooltip: {
		trigger: 'item',
		formatter: "{a} <br/>{b} : {c} ({d}%)"
	},
	color: ['#8fc31f', '#f35833', '#00ccff', '#ffcc00', '#315FA0', '#03B48E'],
	legend: {
		"width": "100%",
		"bottom": '0',
		"itemGap": 6,
		itemWidth: 10,
		itemHeight:10,
		data: ['油站销售', '加汽销售', '充电销售', '超市销售', '餐厅销售', '客房销售', '物业商户销售', '其它销售'],
		formatter: function(name) {
			var oa = ytxszbOption.series[0].data;
			var num = oa[0].value + oa[1].value + oa[2].value + oa[3].value;
			for (var i = 0; i < ytxszbOption.series[0].data.length; i++) {
				if (name == oa[i].name) {
					if(name.length == 4) name = name + '  ';
					return '{a|'+ name + '   ' + (oa[i].value / num * 100).toFixed(2) + '%}   ';
				}
			}
		},
		textStyle:{
			rich:{
				a:{
					width:120
				}
			}
		}
		// formatter: function (name) {
		// 	// 计算当前图例项是第几个
		// 	var index = ytxszbChart.getOption().legend[0].data.indexOf(name);
		// 	// 根据索引判断当前是第几行，然后计算列索引
		// 	var row = Math.floor(index / 2);
		// 	var col = index % 2;
		// 	// 如果是偶数列，则添加换行符
		// 	return col === 0 ? name : ('\n' + name);
		// }
	},
	series: [{
		name: '业态销售占比',
		type: 'pie',
		radius: '55%',
		center: ["50%", "30%"],
		radius: ["25%", "48%"],

		data: [{
				value: 3600,
				name: '油站销售'
			},
			{
				value: 5400,
				name: '加汽销售'
			},
			{
				value: 2900,
				name: '充电销售'
			},
			{
				value: 2500,
				name: '超市销售'
			},
			{
				value: 450,
				name: '餐厅销售'
			},
			{
				value: 3500,
				name: '客房销售'
			},
			{
				value: 3500,
				name: '物业商户销售'
			},
			{
				value: 3500,
				name: '其它销售'
			},
		],
		itemStyle: {
			emphasis: {
				shadowBlur: 10,
				shadowOffsetX: 0,
				shadowColor: 'rgba(0, 0, 0, 0.5)'
			}
		},
		itemStyle: {
			normal: {
				label: {
					show: false,
				},
				borderColor: '#ffffff',
				borderWidth: 10,
			},
			labelLine: {
				show: true
			}
		}
	}]
};


ytxszbChart.setOption(ytxszbOption)
